import React, { Component } from 'react';
import Layout from "./layout"
import { BrowserRouter, Route, Redirect, withRouter } from "react-router-dom"
import { routes } from "./router/index"
import Login from "./views/login"


// router -- 
// layout -- 引入router 

// app -- layout

class App extends Component {
    render() {
        return (
            <div>
                {/* <Layout></Layout> */}

                <BrowserRouter>

                    {
                        routes.map(item => <Route exact={item.exact} key={item.path} path={item.path} render={() => {
                            if (item.path === '/login') {
                                return <item.component />
                            } else {
                                return <Layout routes={item.children} />
                            }
                        }}></Route>)
                    }
                </BrowserRouter>



                {/* <Route path='/login' component={Login}></Route> */}



            </div>
        );
    }
}

export default App
